﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace PickGold.Forms
{
	partial class UCImportData : UserControl
	{
		public UCImportData()
		{
			this.InitializeComponent();
			this.GridView.Columns.Add(new DataGridViewColumn(new DataGridViewComboBoxCell()));
			this.GridView.Columns[0].HeaderCell = new DataGridViewComboBoxColumnHeaderCell();
		}
	}

	class DataGridViewComboBoxColumnHeaderCell : DataGridViewColumnHeaderCell
	{
		private ComboBox _CB;
		public DataGridViewComboBoxColumnHeaderCell()
			: base()
		{
			this._CB = new ComboBox();
			//this._CB.Visible = false;
		}

		protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
		{
			this._CB.Parent = this.DataGridView;
			this._CB.Bounds = cellBounds;
			if (this._CB != null)
				return;

			base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
			if (cellBounds.Width >= cellBounds.Height)
			{
				ComboBoxRenderer.DrawTextBox(graphics, cellBounds, "Text", this.DataGridView.Font, clipBounds, TextFormatFlags.Default, System.Windows.Forms.VisualStyles.ComboBoxState.Hot);
				cellBounds = new Rectangle(cellBounds.Right - cellBounds.Height, cellBounds.Y, cellBounds.Height, cellBounds.Height);
			}
			ComboBoxRenderer.DrawDropDownButton(graphics, cellBounds, System.Windows.Forms.VisualStyles.ComboBoxState.Hot);
		}

		protected override void OnClick(DataGridViewCellEventArgs e)
		{
			base.OnClick(e);
		}
	}
}
